package com.l.web.master.system.group;

import org.l.qiao.Cluster;
import org.l.qiao.KeyType;
import org.l.qiao.annotation.Key;
import org.l.qiao.base.LType;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 严秋旺
 */
public class Group extends Cluster {

    /**
     * 组名
     */
    @Key(keyType = KeyType.MapKey, valueType = LType.LTYPE_STRING, check = "^[\\w\u4e00-\u9fa5]{1,50}$", nullable = false)
    public static final String NAME = "name";

    @Key(keyType = KeyType.MapKey, valueType = LType.LTYPE_STRING, check = "", nullable = true)
    public static final String NOTES = "notes";

    public static final String LIMIT = "limit";

    public static final String CREATED = "created";

    public Group() {
        super();
    }

    public Group(Map<String, Object> map) {
        super(map);
    }

    public boolean checkLimit(String actid, String act) {
        Map<String, Object> limit = getMap(this.LIMIT, new HashMap());
        if (limit.containsKey(actid)) {
            List<String> list = (List<String>) limit.get(actid);
            return list.contains(act);
        } else {
            return false;
        }
    }
}
